#!/usr/bin/env bash
##
# [MySQL 8不允许用grant带密码创建账号，需先创建账号再设置权限](https://www.cnblogs.com/opsprobe/p/14999398.html)
##
set -x
set -eu

SOCKET={{mysql_data_dir}}/mysql.sock

# 创建管理员账号cluster
mysql -uroot -p{{mysql_root_password}}  -S $SOCKET \
-e "set session sql_log_bin = 0; create USER if not exists '{{mysql_admin_user}}'@'%' IDENTIFIED BY '{{mysql_admin_password}}'; GRANT ALL PRIVILEGES ON *.* TO '{{mysql_admin_user}}'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;"
